/**
 * Created by Administrator on 2018/5/10.
 */
import React, { Component } from 'react';
import { connect } from 'react-redux'
import { NavBar} from 'antd-mobile'
import {
  Route,
  Switch,
} from 'react-router-dom'
import Tarbar from '../tarbar/tarbar.js'
import Boss from '../boss/boss.js'
import Genius from '../genius/genius.js'
import User from '../user/user'
function Msg(){
    return <h2>Msg</h2>
}

class DashBoard extends Component {
  render() {
    const user = this.props.user
    const navList = [
        {
            path:'/boss',
            title:'牛人列表',
            icon:'index',
            hide: user.type==='genius',
            component: Boss
        },
        {
            path:'/genius',
            title:'BOSS列表',
            icon:'index',
            hide: user.type==='boss',
            component: Genius
        },
        {
            path:'/msg',
            title:'消息列表',
            icon:'msg',
            component: Msg
        },
        {
            path:'/user',
            title:'个人中心',
            icon:'user',
            component: User
        }
    ]
    const path = this.props.location.pathname
    return (
        <div className="dashboard">
            <NavBar mode="dark" className="fix-header">{navList.find(v=>v.path===path).title}</NavBar>
            <div style={{marginTop:45}}>
                <Switch>
                    {navList.map(v=>(
                      <Route key={v.title} path={v.path} component={v.component}></Route>
                    ))}
                </Switch>
            </div>
            <Tarbar navList={navList}></Tarbar>
        </div>
    );
  }
}
const mapStatetoProps =(state)=>{
  return state
}

const actionCreators = {}
DashBoard = connect(mapStatetoProps,actionCreators)(DashBoard)
export default DashBoard;